package alog;

public class twoThread implements Runnable{
    int i = 0;
    public static void main(String[] args) {
        twoThread t = new twoThread();
        new Thread(t, "A").start();
        new Thread(t, "B").start();
    }

    @Override
    public void run() {
        while(true){
            synchronized (this){
                notify();
                if(i >= 100)
                    break;
                if(i < 100){
                    i++;
                    System.out.println(Thread.currentThread().getName() + "-->" +  i);
                }
                try {
                    wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
